package MIPS;

/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
import java.util.concurrent.Semaphore;
import java.util.logging.Level;
import java.util.logging.Logger;

public class pizarra {

    private volatile String texto = null;
    private volatile int[] IR = null;
    private volatile int RL = -1;
    private volatile int Imm = -1;
    private volatile int RA = -1;
    private volatile int RB = -1;
     private volatile int AluOutPut = -1;
    private volatile int PC = -1;
    private Semaphore m = null;
    private boolean copiado = true;
    private boolean cambio = false;
   

    public int[] getIR() {
        return IR;
    }

    public void setIR(int[] IR) {
        this.IR = IR;
    }
    
     public int getPC() {
        return PC;
    }

    public void setPC(int PC) {
        this.PC = PC;
    }

    public boolean getCopiado() {
        return copiado;
    }
    
     public void setCopiado(boolean copiado) {
        this.copiado = copiado;
    }
        
    public int getImm() {
        return Imm;
    }

    public void setImm(int Imm) {
        this.Imm = Imm;
    }

    public int getRA() {
        return RA;
    }

    public void setRA(int RA) {
        this.RA = RA;
    }

    public int getRB() {
        return RB;
    }

    public void setRB(int RB) {
        this.RB = RB;
    }

    public int getRL() {
        return RL;
    }

    public void setRL(int RL) {
        this.RL = RL;
    }

    public String getTexto() {
        return texto;
    }

    public void setTexto(String texto) {
        this.texto = texto;
    }

    public void setText(String txt) {
        texto = txt;
    }

    public String getText() {
        return texto;
    }

    boolean isLocked() {
        return m.availablePermits() > 0 ? false : true;//tryAcquire();//getQueueLength()>0?false:true;
    }

    public pizarra() {
        m = new Semaphore(1);
        texto = "";
    }

    void lock() {
        try {
            m.acquire();
        } catch (InterruptedException ex) {
            Logger.getLogger(pizarra.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    void unLock() {
        m.release();
    }

    void setCambio(boolean b) {
        this.cambio = b;
    }

    boolean getCambio() {
        return cambio;
    }

    void setALU(int AluOutPut) {
        this.AluOutPut = AluOutPut;
    }
    
     public int getALU() {
        return AluOutPut;
    }
}
